package com.zc.guoxuan.controller;

import com.alibaba.fastjson.JSON;
import com.zc.custom.domain.ChargeCustomOrderInfo;
import com.zc.guoxuan.domain.CreateOrder;
import com.zc.guoxuan.domain.SettlementOrder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author glb
 * @Date 2023/8/3 11:57
 * @Version 1.0
 */
@Controller
public class OrderController {

    /** 创建订单*/
    @PostMapping("/createOrder")
    @ResponseBody
    public void createOrderInterface( CreateOrder createOrder){
        ChargeCustomOrderInfo chargeCustomOrderInfo=new ChargeCustomOrderInfo();
        chargeCustomOrderInfo.setDeviceCode(createOrder.getFlowNo());
        chargeCustomOrderInfo.setGunPos(Integer.parseInt(createOrder.getGunAddress()));
        chargeCustomOrderInfo.setOrderInfoCode(createOrder.getFlowNo());
        chargeCustomOrderInfo.setChargeModel(Integer.parseInt(createOrder.getChargeMode()));
        chargeCustomOrderInfo.setChargeQuantity(createOrder.getChargeQuantity());
        System.out.println(JSON.toJSON(createOrder));
    }

    /** 结算订单*/
    @PostMapping("/settlementOrder")
    @ResponseBody
    public void settlementOrderInterface(SettlementOrder settlementOrder){
        ChargeCustomOrderInfo chargeCustomOrderInfo=new ChargeCustomOrderInfo();
        chargeCustomOrderInfo.setDeviceCode(settlementOrder.getPileNum());
        //chargeCustomOrderInfo.setStartTime(settlementOrder.getStartDate());
        //chargeCustomOrderInfo.setEndTime(settlementOrder.getEndDate());
        //chargeCustomOrderInfo.setTotalPower(settlementOrder.getChargeEnergy());
        chargeCustomOrderInfo.setTotalTime(Long.valueOf(settlementOrder.getChargeTime()));
        chargeCustomOrderInfo.setStartSoc(settlementOrder.getStartSOC());
        chargeCustomOrderInfo.setEndSoc(settlementOrder.getEndSOC());
        chargeCustomOrderInfo.setOrderInfoCode(settlementOrder.getTransactionFlow());
        chargeCustomOrderInfo.setElecNums(settlementOrder.getElecNums());
        chargeCustomOrderInfo.setStopReason(settlementOrder.getIsNend());
        chargeCustomOrderInfo.setCarVin(settlementOrder.getCarVIN());
        System.out.println(JSON.toJSON(settlementOrder));

    }
}
